Skip to content

fix: improve ZWS handling performance on iOS - #113

Merged
IvanIhnatsiuk merged 1 commit into
developmentfrom
fix/improve-ZWS-handling-performance-on-iOS
Jul 2, 2026
Merged

fix: improve ZWS handling performance on iOS#113
IvanIhnatsiuk merged 1 commit into
developmentfrom
fix/improve-ZWS-handling-performance-on-iOS

Conversation

@IvanIhnatsiuk

@IvanIhnatsiuk IvanIhnatsiuk commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

This pull request introduces several improvements to the handling of zero-width spaces (ZWS) in enriched text input, focusing on better style detection, more robust editing, and improved method signatures. The main changes include passing ZWS styles explicitly to relevant methods, ensuring batch editing of text storage for performance, and refining how placeholder logic is applied for block elements.

Zero-width space handling and style detection:

  • Refactored ZeroWidthSpaceUtils methods (removeSpacesIfNeededinInput and addSpacesIfNeededinInput) to accept an explicit zwsStyles parameter, ensuring consistent style checks and reducing redundant style computation.
  • Added a new overload findAnyZWSStylesInInput:range:zwsStyles: to check for ZWS styles within a range using a provided styles array, improving accuracy and efficiency when determining where ZWS handling is needed.

Batch editing and performance:

  • Wrapped text storage modifications in beginEditing/endEditing calls during ZWS removal and insertion, reducing the number of layout and notification events for better performance and stability.

Code quality and correctness:

  • Updated pointer checks from nullptr to nil for Objective-C compatibility in handleZeroWidthSpacesInInput.

HTML parsing logic:

  • Adjusted placeholder logic in traverseNode: to only insert placeholders for list items and check list tags, not for all paragraph tags, making block placeholder insertion more precise.

Test Plan

Provide clear steps so another contributor can reproduce the behavior or verify the feature works.
For example:

  • Steps to reproduce the bug (if this is a bug fix)
  • Steps to verify the new feature
  • Expected vs actual results
  • Any special conditions or edge cases to test

Screenshots / Videos

Include any visual proof that helps reviewers understand the change — UI updates, bug reproduction or the result of the fix.

Compatibility

OS Implemented
iOS
Android

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors iOS zero-width space (ZWS) handling in EnrichedTextInputView to reduce redundant style detection and improve text storage edit performance, and it tightens HTML parsing placeholder insertion rules for block elements.

Changes:

  • Passes precomputed zwsStyles through ZWS add/remove flows and adds an overload for style checks to avoid recomputing styles repeatedly.
  • Wraps ZWS insertion/removal mutations in NSTextStorage beginEditing/endEditing to reduce intermediate layout/notification churn.
  • Refines HTML empty-block placeholder insertion to focus on list-related tags.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
ios/utils/Text/ZeroWidthSpaceUtils.mm Refactors ZWS style detection to accept explicit styles and batches text storage edits for performance.
ios/parser/EnrichedHTMLToAttributedStringParser.mm Narrows when ZWS placeholders are inserted for empty block elements during HTML traversal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ios/utils/Text/ZeroWidthSpaceUtils.mm
Comment thread ios/parser/EnrichedHTMLToAttributedStringParser.mm
@IvanIhnatsiuk
IvanIhnatsiuk merged commit ef15adf into development Jul 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants